<template>
    <div class="login-bg">
        <div class="login layui-anim layui-anim-up">
            <div class="message">租赁管理系统</div>
            <div id="darkbannerwrap"></div>
            <form class="layui-form">
                <input class="layui-input" v-model="username" type="text" placeholder="用户名">
                <hr class="hr15">
                <input class="layui-input" v-model="password" type="password" placeholder="密码">
                <hr class="hr15">
                <button class="btn" @click="loginFn()">登录</button>
                <hr class="hr20">
            </form>
        </div>
    </div>
</template>

<script>
export default {
    name: "Login",
    data() {
        return {
            username: null,
            password: null
        };
    },
    methods: {
        loginFn: function() {
            this.axios({
                method: "post",
                url: "login#!method=post",
                withCredentials: true,
                data: {
                    username: this.username,
                    password: this.password
                }
            })
                .then(ret => {
                    if (ret.data.code == 1) {
                        localStorage.setItem(
                            "token",
                            `${this.$cookies.get("XSRF-TOKEN")}`
                        );
                        this.$router.push({ name: "homeLink" });
                    }
                    console.log(ret);
                })
                .catch(err => {
                    console.log(err);
                });
        }
    }
};
</script>

<style scoped>
* {
    margin: 0px;
    padding: 0px;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.login-bg {
    height: 100vh;
    background: url(../assets/img/login_bg.png) no-repeat center;
    background-size: cover;
    overflow: hidden;
}
.login {
    margin: 120px auto 0 auto;
    min-height: 420px;
    max-width: 420px;
    padding: 40px;
    background-color: #ffffff;
    margin-left: auto;
    margin-right: auto;
    border-radius: 4px;
    box-sizing: border-box;
}
.login a.logo {
    display: block;
    height: 58px;
    width: 167px;
    margin: 0 auto 30px auto;
    background-size: 167px 42px;
}
.login .message {
    margin: 10px 0 0 -58px;
    padding: 18px 10px 18px 60px;
    background: #189f92;
    position: relative;
    color: #fff;
    font-size: 16px;
    text-align: left;
}
.login #darkbannerwrap {
    background: url(../assets/img/aiwrap.png);
    width: 18px;
    height: 10px;
    margin: 0 0 20px -58px;
    position: relative;
}

.login input[type="text"],
.login input[type="file"],
.login input[type="password"],
.login input[type="email"],
select {
    border: 1px solid #dcdee0;
    vertical-align: middle;
    border-radius: 3px;
    height: 50px;
    padding: 0px 16px;
    font-size: 14px;
    color: #555555;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}
.login input[type="text"]:focus,
.login input[type="file"]:focus,
.login input[type="password"]:focus,
.login input[type="email"]:focus,
select:focus {
    border: 1px solid #27a9e3;
}
.login .btn {
    display: inline-block;
    vertical-align: middle;
    padding: 12px 24px;
    margin: 0px;
    font-size: 18px;
    line-height: 24px;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    color: #ffffff;
    background-color: #189f92;
    border-radius: 3px;
    border: none;
    -webkit-appearance: none;
    outline: none;
    width: 100%;
}
.login hr {
    background: #fff url() 0 0 no-repeat;
}
.login hr.hr15 {
    height: 15px;
    border: none;
    margin: 0px;
    padding: 0px;
    width: 100%;
}
.login hr.hr20 {
    height: 20px;
    border: none;
    margin: 0px;
    padding: 0px;
    width: 100%;
}
</style>

